import { PokerSet } from "../poker/set";
import { landLordChecker } from "./setChecker_lanlord";
import { SetInfo } from "./setInfo";

export const enum GAME_TYPE {
  LANDLORD = 0,   // 斗地主
  ROYALIST,       // 保皇
  ZHAJINHUA,      // 扎金花
  SHENGJI,        // 升级
}

export interface IRecorder {
  InitRecorder(): void;
  AddPokerSet(playerPokers: PokerSet): void;
  RemovePokerSet(cards: PokerSet): void;
  SequenceJsonEncode(): string;
}

export interface IAnalyzer {
  InitAnalyzer(): void;
  AddPokerSet(pokers: PokerSet): void;
  RemovePokerSet(pokers: PokerSet): void;
  GetMinPlayableCards(): PokerSet
  GetUseableCards(setType: SetInfo): Array<PokerSet>;
}

export interface ISetChecker {
  GetSetInfo(set: PokerSet): SetInfo | string;
}

export function GetGameName(gameType: number): string {
  switch (gameType) {
    case GAME_TYPE.LANDLORD: return "斗地主";
    case GAME_TYPE.ROYALIST: return "保皇";
    case GAME_TYPE.SHENGJI: return "扎金花";
    case GAME_TYPE.ZHAJINHUA: return "升级";
    default: return "undefined";
  }
}

/**
 * 获取适用于某一种游戏的扑克集
 * @param gameType
 * @returns
 */
export function NewSetChecker(gameType: number): ISetChecker {
  switch (gameType) {
    case GAME_TYPE.LANDLORD: return new landLordChecker();
    case GAME_TYPE.ROYALIST:
    case GAME_TYPE.SHENGJI:
    case GAME_TYPE.ZHAJINHUA:
    default: return null as any;
  }
}
